package com.iflyun.goodsshow.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.print.attribute.standard.MediaSize.Other;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.iflyun.goodsshow.dao.GoodsDao;
import com.iflyun.goodsshow.entity.Analysis;
import com.iflyun.goodsshow.entity.DayDetail;
import com.iflyun.goodsshow.entity.Goods;
import com.iflyun.goodsshow.entity.Shop;
import com.iflyun.goodsshow.service.GoodsService;

@Service("goodService")
public class GoodsServiceImpl implements GoodsService {

	@Autowired
	public GoodsDao Goodsdao;

	@Override
	public boolean InsertGoods(String day, String shopcode, String goodscode, String totalcount) {
		return Goodsdao.InsertGoods(day, shopcode, goodscode, totalcount);
	}

	@Override
	public DayDetail getGoodsInfo(String shopname, String goodsname, String day) {
		return Goodsdao.getGoodsInfo(shopname, goodsname, day);
	}

	@Override
	public List<Goods> getGoodsName() {
		return Goodsdao.getGoodsName();
	}

	@Override
	public List<Shop> getShopName() {
		return Goodsdao.getShopName();
	}

	@Override
	public HashMap<String,Object>  getGoodsByName(String shopcode, String goodscode, String starttime, String endtime,int pageNo,int pageSize) {
		Page<?> page=PageHelper.startPage(pageNo, pageSize,true);
		HashMap<String,Object>  map = new HashMap<String,Object>();
		List<Analysis> list= Goodsdao.getGoodsByName(shopcode, goodscode, starttime, endtime);
		map.put("analysis", list);
		long count = page.getTotal();
		map.put("pageCount", count);
		
		return map;
	}


}
